package ru.vsu.amm.fuzzy.problems.ui;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;

/**
 * 
 * @author Иванов Илья
 * @since 22 января 2013
 *
 */
public class AboutDialog extends JDialog {

	private static final long serialVersionUID = -110558464914595457L;
	
	private final JPanel contentPanel = new JPanel();

	/**
	 * Create the dialog.
	 */
	public AboutDialog(FuzzyFrame owner, String html) {
		super(owner, true);
		setResizable(false);
		
		setTitle("О программе");
		setBounds(100, 100, 342, 233);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		
		JPanel htmlPanel = new JPanel();
		htmlPanel.setBounds(10, 11, 307, 140);
		contentPanel.add(htmlPanel);
		htmlPanel.setLayout(null);
		
		JLabel htmlViewer = new JLabel(html);
		htmlViewer.setHorizontalAlignment(SwingConstants.CENTER);
		htmlViewer.setVerticalAlignment(SwingConstants.TOP);
		htmlViewer.setBounds(20, 12, 269, 122);
		htmlPanel.add(htmlViewer);
		
		JPanel buttonPanel = new JPanel();
		buttonPanel.setBounds(10, 158, 307, 34);
		contentPanel.add(buttonPanel);
		
		JButton close = new JButton("Закрыть");
		close.setBounds(111, 4, 84, 26);
		close.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				AboutDialog.this.setVisible(false);
				AboutDialog.this.dispose();
			}
		});
		buttonPanel.setLayout(null);
		buttonPanel.add(close);
		
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		setLocationRelativeTo(getOwner());
		setVisible(true);
	}
}